package coffee.wechat;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXTextObject;

public class MainActivity extends Activity {

	private static final String APP_ID = "wxd0a1372ebfdfdad7";
	
	//d15264f1b6786f6306de88766f3f3830
	//79b59e3fe94d01fc44c8d3aa80f74909
	private static final String APP_KEY = "c385f279a6f4c4240a49c1adb42a6075";
	
	private IWXAPI api;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //
        setContentView(R.layout.activity_main);
        
        api = WXAPIFactory.createWXAPI(this, APP_ID, true);
        api.registerApp(APP_ID);
        
        WXTextObject textObj = new WXTextObject();
        textObj.text = "hello";
        
        WXMediaMessage msg = new WXMediaMessage();
        msg.mediaObject = textObj;
        msg.description = "xxx";
        
        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = String.valueOf(System.currentTimeMillis());
        req.message = msg;
        
        api.sendReq(req);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
